﻿/*----------------------------------------------------------------
// Copyright (C) 2012 zhangqiang
// 版权所有。 
//
// 文件名：FrameworkInstaller.cs
// 文件功能描述：框架的安装类
//
// 
// 创建标识：2012-10-21 zhangqiang
//
// 修改标识：
// 修改描述：
//
//
//----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Castle.MicroKernel.Registration;
using System.Configuration;
using WebHelper.SessionHandler;
using WebPlatform.FiltersAndSession;
using Cache.Contract;
using Cache.MemoryCache;

namespace WebPlatform.Windsor
{
    /// <summary>
    /// 框架的安装类
    /// </summary>
    public class FrameworkInstaller : IWindsorInstaller
    {
        /// <summary>
        /// 安装方法
        /// </summary>
        /// <param name="container">容器</param>
        /// <param name="store">配置文件</param>
        public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
        {
            var sessionType = ConfigurationManager.AppSettings["SessionHandler"];
            //string cache = ConfigurationManager.AppSettings["CacheHandler"];
            //var p = Type.GetType(sessionType);
            //var c = Type.GetType(cache);
            container.Register(
                  Component.For<ICache>().ImplementedBy<MemoryCache>().LifestyleSingleton(),
                  Component.For<Sessions>().LifestyleSingleton(),
                  //Component.For<OperationHandler>().LifestyleSingleton(),
                  Component.For(typeof(ISessionHandler)).ImplementedBy(Type.GetType(sessionType)).LifestyleSingleton()
                );
        }
    }
}